package com.ljw.punishment.enginelistener;

import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.jeasy.rules.api.Facts;
import org.jeasy.rules.api.Rules;
import org.jeasy.rules.api.RulesEngineListener;
import org.springframework.stereotype.Component;


@Slf4j
@Component(value = "logRuleEngineListener")
public class LogRuleEngineListener implements RulesEngineListener {

    @Override
    public void beforeEvaluate(Rules rules, Facts facts) {
        log.info("====logRuleEngineListener::beforeEvaluate ==== 加载规则:{}", JSONObject.toJSONString(rules));
        log.info("====logRuleEngineListener::beforeEvaluate ==== 加载事实:{}", JSONObject.toJSONString(facts));
    }

    @Override
    public void afterExecute(Rules rules, Facts facts) {
        log.info("==== logRuleEngineListener::afterExecute ==== 加载规则:{}", JSONObject.toJSONString(rules));
        log.info("==== logRuleEngineListener::afterExecute ==== 加载事实:{}", JSONObject.toJSONString(facts));
    }
}
